﻿using System.Data;
using System.Data.SqlClient;
using System.Drawing;

namespace Tank90.Services
{
    public class LoadMapService
    {
        /// <summary>
        ///     绘制地图
        /// </summary>
        /// <param name="graphics">绘图工具</param>
        /// <param name="check">关卡</param>
        public void DrawMap(Graphics graphics, int check)
        {
        }

        /// <summary>
        /// </summary>
        /// <param name="checkPoint">连接字符串</param>
        /// 要返回draw能够读出的数据类型
        private void GetDataSource(int checkPoint)
        {
            string strcon = "Data Source=.;Initial Catalog=Tank;Integrated Security=true";
            string cmdStirng = "select * from Element";
            var connect = new SqlConnection(strcon);
            var cmd = new SqlCommand(cmdStirng, connect);
            try
            {
                if (connect.State == ConnectionState.Closed)
                {
                    var dataSet = new DataSet();
                    connect.Open();
                    IDataReader dr = cmd.ExecuteReader();


                    dr.Close();
                    var da = new SqlDataAdapter(cmdStirng, connect);
                    da.Fill(dataSet);
                    dr.Close();
                }
            }
            catch (SqlException e)
            {
            }
            finally
            {
                if (connect != null && connect.State == ConnectionState.Open)
                {
                    connect.Dispose();
                }
            }
        }

        /// <summary>
        ///     增加元素
        /// </summary>
        private void AddData()
        {
        }

        /// <summary>
        ///     删除元素
        /// </summary>
        private void DelData()
        {
        }

        /// <summary>
        ///     修改元素
        /// </summary>
        private void ModifyData()
        {
        }
    }
}